//
//  SEGBillDeatilDisFeeView.m
//  ExcellentHome
//
//  Created by 刘山 on 16/12/15.
//  Copyright © 2016年 陈区. All rights reserved.
//

#import "SEGBillDeatilDisFeeView.h"

@interface SEGBillDeatilDisFeeView ()
@property (nonatomic, assign) BOOL isHeader; // 是否是头部优惠提示
@end

@implementation SEGBillDeatilDisFeeView

- (void)setupUIWithIsHeader:(BOOL)isHeader {
    self.isHeader = isHeader;
    if (self.isHeader) {
        UIView *lineView = [UIView new];
        lineView.backgroundColor = kColor_L2;
        [self addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.right.mas_equalTo(0);
            make.height.mas_equalTo(1);
        }];
        
        UIImageView *tipImageView = ({
            UIImageView *imageView = [[UIImageView alloc] init];
            imageView.contentMode = UIViewContentModeScaleToFill;
            imageView.image = [UIImage imageWithContentsOfFile:SEGPicName(@"label_pay_activity")];
            [self addSubview:imageView];
            imageView;
        });
        [tipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(27);
            make.height.mas_equalTo(13);
            make.top.mas_equalTo(11.5);
            make.left.mas_equalTo(15);
        }];
    }
    
    [self addSubview:self.contentLabel];
    [self.contentLabel setFont:kFont_13];
    [self.contentLabel setTextColor:self.isHeader ? kColor_1 : kColor_S1];
    self.contentLabel.numberOfLines = 0;
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker* make) {
        make.edges.mas_equalTo(0);
        make.height.mas_equalTo(0);
    }];
    
    self.backgroundColor = self.isHeader ? kColor_W : [UIColor colorWithHexString:@"#FEFED9"];
}

- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc] init];
    }
    return _contentLabel;
}

- (void)updateUIWithText:(NSString *)title {
    self.contentLabel.text = title;
    if (!title || title.length == 0) {
        [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
            make.edges.mas_equalTo(0);
            make.height.mas_equalTo(0);
        }];
    } else {
        [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker* make) {
            make.top.mas_equalTo(self.isHeader ? 10 : 7);
            make.bottom.mas_equalTo(self.isHeader ? -10 : -7);
            make.left.mas_equalTo(self.isHeader ? 47 : 15);
            make.right.mas_equalTo(-15);
            make.height.mas_greaterThanOrEqualTo(5);
        }];
    }
}

@end
